package com.example.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {
    public static final String EXCHANGE_NAME = "FANOUT_EXCHANGE";


    public static final String QUEUE1_RECV_NAME = "QR1";
    public static final String QUEUE2_RECV_NAME = "QR2";
    public static final String QUEUE3_RECV_NAME = "QR3";


    @Bean
    public static FanoutExchange createChatExchange() {
        return new FanoutExchange(EXCHANGE_NAME, true, false);
    }


    @Bean
    Queue createRQueue1() {
        return new Queue(QUEUE1_RECV_NAME, true, false, false);
    }

    @Bean
    Queue createRQueue2() {
        return new Queue(QUEUE2_RECV_NAME, true, false, false);
    }

    @Bean
    Queue createRQueue3() {
        return new Queue(QUEUE3_RECV_NAME, true, false, false);
    }


    @Bean
    Binding createQR1BindWithFanoutExchange() {
        return BindingBuilder.bind(createRQueue1()).to(createChatExchange());
    }

    @Bean
    Binding createQR2BindWithFanoutExchange() {
        return BindingBuilder.bind(createRQueue2()).to(createChatExchange());
    }

    @Bean
    Binding createQR3BindWithFanoutExchange() {
        return BindingBuilder.bind(createRQueue3()).to(createChatExchange());
    }


}



